<!DOCTYPE html>
<html lang="zh-CN">
<head>
  	<meta charset="utf-8">
  	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<#include "/common/plateform/include/common-base.html" >
  	<title>工程管理</title>
  	<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
</head>
<body class="${sysColor} sidebar-collapse">
<div class="wrapper">

  <!-- top start -->
	<#include "/common/plateform/top.html">
  <!-- top end -->
  <!-- left start -->
  <!-- left end-->

  <div class="content-wrapper">
    <!-- Main start -->
	<section class="content">
      <div class="row">
        <div class="col-xs-12">
        
          <!------搜索  start ------->
          <div class="box box-default  box-solid">
             <!--搜索title  start -->
            <!--搜索title  end -->
            <div class="box-body">
			  <form id="searchFrom" class="form-horizontal" action="javascript:void(0);">
				  	<input type="hidden" name="formName" value="searchForm"/>
				  <#if (loginUser.sysFlag =='1')>
					  <!-- 1平台管理员 -->
					  <input type="hidden" name="pageName" value="uct-sys-list"/>
				  <#elseif (loginUser.sysFlag =='2')>
					  <!-- 2机构管理员 -->
					  <input type="hidden" name="pageName" value="uct-sys-list"/>
				  	  <#if (loginUser.user.customerType =='org')>
					  		<input type="hidden" name="uctSys.wi_orgId" value="${loginUser.dataOrgIds }${loginUser.orgId}"/>
				      <#else>
						  	<input type="hidden" name="uctSys.w_createUser" value="${loginUser.userEname}"/>
					  </#if>
				  </c:if>
				  <#elseif (loginUser.sysFlag =='3')>
					  <!-- 3机构内系统管理员-需要uctUserSys关联查询 -->
					  <input type="hidden" name="pageName" value="uct-sys-user-list"/>
					  <input type="hidden" name="uctUserSys.w_userId" value="${loginUser.userId}"/>
			      </#if>
				  	<input type="hidden" name="orderBy" value="uctSys.create_time desc"/>

				<div class="form-group">
					<div class="col-sm-4 col-xs-4" data-step="1" data-intro="点此按钮快速创建工程">
						<button  onclick="toAdds();" class="btn btn-success p10" type="button"><i class="fa fa-plus-circle"></i> &nbsp;创建工程 </button>
					</div>
					<div class="col-sm-4 hidden-xs">
						<h2 class="f30 fx2 hidden"></h2>
					</div>
					<div class="col-sm-4 col-xs-8">
						<div class="input-group">
							<input class="form-control" name="uctSys.wl_sysEname" maxlength="50" placeholder="您可以输入工程标识进行筛选"/>
							<div class="input-group-addon fcur" onclick="getTableDataNew();">
								<i class="fa fa-search text-info"></i>
							</div>
						</div>
					</div>
				</div>
			  </form>
            </div>
	     </div>
			<!------- 搜索 end -------->
        <!------- 列表 start -------->
          <div class="box box-success">
			  <div class="box-header with-border">
				  <h3 class="box-title">工程列表 [共计<span id="dataListTotalCount">0</span>条数据]</h3>
				  <div class="box-tools pull-right">
					  <button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>
				  </div>
			  </div>
              <div class="box-body">
					<table id="dataList" class="hidden table table-bordered table-hover" >
					<thead class="bg-success">
					<tr>
						<th class="text-center">序号</th>
						<th>工程名称</th>
						<th>工程标识</th>
						<th>管理端主题</th>
						<th>创建时间</th>
						<th>操作</th>
					</tr>
					</thead>
					<tbody id="dataList-body">
					</tbody>
				  </table>
				  <div id="dataListNew-body"></div>
            </div>
			  <div class="box-footer">
				  <center>
					  <ul id="dataListNew-page"></ul>
				  </center>
			  </div>
           </div>
        <!------- 列表 end -------->
        </div>
      </div>
    </section>
    <!-- Main end -->

   <div class="modal fade" id="my_modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
	<div class="modal-dialog" style="top:15%; width:70%;">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
						<h4 class="modal-title">
							<font class="red">1、创建工程</font>&nbsp;&nbsp;<i class="fa fa-angle-right fx8"></i>&nbsp;&nbsp;
							<font class="fx8">2、创建服务</font>&nbsp;&nbsp;
						</h4>
					</div>
					<div class="modal-body">
						<form class="form-horizontal addFormBody" role="form" id="submitForm">
							<input type="hidden" name="pageName" value="uct-sys" />
							<input type="hidden" name="formName" value="addForm" />
							<input type="hidden" id="formToken" name="formToken"  value="${formToken}" />
							<input type="hidden" name="uctSys.orgId" value="${loginUser.orgId}"/>
							<input type="hidden" name="uctSys.sysPass" value="iussoft2018"/>
							<input type="hidden" name="uctSys.createTime" value=""/>
							<div class="box-body">
					          <div>
					            <div class="tab-content">
					              <div class="tab-pane active">
					                <div class="form-group">
					                  <label class="col-sm-3 control-label" >工程名称</label>
										<div class="col-sm-8">
					                    <input type="text" id="sysCname" data-name="sysCname" name="uctSys.sysCname" class="form-control clean"  placeholder="必填项，输入工程中文名称" data-bv-notempty="true" data-bv-notempty-message="必填项，输入工程中文名称" maxlength="10"/>
					                  </div>
					                </div>
					                <div class="form-group">
					                  <label class="col-sm-3 control-label" >英文标识</label>
					                  <div class="col-sm-8">
					                  <input id="sysEname" name="uctSys.sysEname" data-name="sysEname" class="form-control clean" maxlength="15"  placeholder="必填项，小写英文或数字，且不能以数字开头" data-bv-notempty="true" data-bv-notempty-message="必填项，小写英文或数字，且不能以数字开头" data-bv-regexp="true" data-bv-regexp-regexp="^[a-z][a-z0-9]*$" data-bv-regexp-message="必须是小写英文或数字，且不能以数字开头"/>
					                  </div>
					                </div>
					                <div class="form-group hidden">
					                  <label class="col-sm-3 control-label" >工程域名</label>
					                  <div class="col-sm-8">
					                  	<input id="methodName" name="uctSys.delStatus" data-name="delStatus" class="form-control clean" />
					                  </div>
					                </div>
					                
					                <div class="form-group hidden">
					                  <label class="col-sm-3 control-label" >排序值</label>
					                  <div class="col-sm-8">
					                  <input id="orderNum" name="uctSys.orderNum" data-name="orderNum" class="form-control clean"  />
					                  </div>
					                </div>
					                
					                <div class="form-group">
					                  <label class="col-sm-3 control-label" >管理端主题</label>
					                  <div class="col-sm-8">

										  <div class="input-group">
											  <input class="form-control" name="uctSys.sysColor" data-name="sysColor"
													 readonly="readonly" id="input_sysColor" value="skin-blue"/>
											  <div class="input-group-addon red">
												  <button type="button" class="btn btn-primary btn-xs" onclick="openThemeModal('input_sysColor')"> <i class="fa fa-search"></i> 选择其他主题</button>
											  </div>
										  </div>
					                  </div>
					                </div>
									  <div class="form-group">
										  <label class="col-sm-3 control-label" >用户中心</label>
										  <div class="col-sm-8 form-control-static">
											  <input type="hidden" id="input_user_center_flag" name="uctSys.userCenterFlag" data-name="userCenterFlag" value="F"/>
											  <input type="radio" value="T" name="radio_userCenterFlag"  onclick="checkIsUserCenter('T','input_user_center_flag')"/> 是
											  <input type="radio" value="F" name="radio_userCenterFlag"  onclick="checkIsUserCenter('F','input_user_center_flag')"  checked /> 否
										  </div>
									  </div>
									  <div class="form-group hidden" id="div_userCenter">
										  <label class="col-sm-3 control-label" >用户中心主题</label>
										  <div class="col-sm-8">

											  <div class="input-group">
												  <input class="form-control clean" name="uctSys.userCenterColor" data-name="userCenterColor"
														 readonly="readonly" id="input_userCenterColor"/>
												  <div class="input-group-addon red">
													  <button type="button" class="btn btn-primary btn-xs" onclick="openThemeModal('input_userCenterColor')"> <i class="fa fa-search"></i> 选择其他主题</button>
												  </div>
											  </div>
											  <div class="red f12"><i class="fa fa-info-circle fx2"></i> 开启后，将同步创建用户中心前端界面结构，在此设置主题色调。</div>
										  </div>
									  </div>
					                
					                <div class="form-group hidden">
					                  <label class="col-sm-3 control-label" >工程描述</label>
					                  <div class="col-sm-8">
					                  <textarea rows="3" cols="9" id="sysRemark" name="uctSys.sysRemark" data-name="sysRemark"  class="form-control clean"></textarea>
					                  </div>
					                </div>
					              </div>					             
					              <!-- /.tab-pane -->
					            </div>
					            <!-- /.tab-content -->
					          </div>
					          <!-- nav-tabs-custom -->
					        </div>
			                <div class="box-footer">
				                <button type="button" class="btn btn-danger pull-right btn-lg" onclick="saveItem('submitForm');"><i class="fa fa-plus-circle"></i> 创建工程</button>
				            </div>
						</form>
					</div>
				</div>
				<!-- /.modal-content -->
			</div>		
</div>

  <div class="modal fade" id="my_modal_create" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
	  <div class="modal-dialog">
		  <div class="modal-content">
			  <div class="modal-header">
				  <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
				  <h4 class="modal-title">
					  <font color="red">第二步、生成项目结构</font>&nbsp;
				  </h4>
			  </div>
			  <div class="modal-body">
				  <form class="form-horizontal addFormBody" role="form" id="createForm">
					  <div class="box-body">
						  <div>
							  <div class="tab-content">
								  <div class="tab-pane active">
									  <div class="form-group">
										  <label class="col-sm-3 control-label" >工程名称</label>
										  <div class="col-sm-8">
											  <input type="text" readonly="readonly" data-name="sysCname" name="sysCname" class="form-control clean"/>
										  </div>
									  </div>
									  <div class="form-group">
										  <label class="col-sm-3 control-label" >工程标识</label>
										  <div class="col-sm-8">
											  <input name="sysEname" readonly="readonly"  data-name="sysEname" class="form-control clean"/>
										  </div>
									  </div>
									  <div class="form-group">
										  <label class="col-sm-3 control-label" >管理后台主题</label>
										  <div class="col-sm-8">
											  <input name="sysColor" readonly="readonly" data-name="sysColor" class="form-control clean"/>
										  </div>
									  </div>

									  <div class="form-group hidden">
										  <label class="col-sm-3 control-label" >含用户中心</label>
										  <div class="col-sm-8">
											  <input name="userCenterFlag" readonly="readonly" data-name="userCenterFlag" class="form-control clean"/>
										  </div>
									  </div>
									  <div class="form-group hidden">
										  <label class="col-sm-3 control-label" >用户中心主题</label>
										  <div class="col-sm-8">
											  <input name="userCenterColor" readonly="readonly" data-name="userCenterColor" class="form-control clean"/>
										  </div>
									  </div>
								  </div>
								  <!-- /.tab-pane -->
							  </div>
							  <!-- /.tab-content -->
						  </div>
						  <!-- nav-tabs-custom -->
					  </div>
					  <div class="box-footer">
						  <button type="button" class="btn btn-danger pull-right" onclick="createWebProject();">下一步</button>
					  </div>
				  </form>
			  </div>
		  </div>
		  <!-- /.modal-content -->
	  </div>
  </div>

<div class="modal fade" id="my_modal_server" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog" style="width:70%;">
	  <div class="modal-content">
		  <div class="modal-header">
			  <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
			  <h4 class="modal-title">
				  <font class="fx8">1、创建工程</font>&nbsp;&nbsp;<i class="fa fa-angle-right fx8"></i>&nbsp;&nbsp;
				  <font class="red">2、创建服务</font>&nbsp;&nbsp;
			  </h4>
		  </div>
		  <div class="modal-body">
			  <form class="form-horizontal serverFormBody" role="form" id="serverForm" action="javascript:;">
				  <div class="box-body">
					  <div>
						  <div class="tab-content">
							  <div class="tab-pane active">
								  <div class="panel panel-default">
									  <input type="hidden" name="pageName" value="server-list">
									  <input type="hidden" name="formName" value="addForm">
									  <input type="hidden" name="tInterfaceRegister.methodName" value="default"/>
									  <input type="hidden" name="tInterfaceRegister.flag" value="0"/>
									  <input type="hidden" name="tInterfaceRegister.reserve2" value="public"/>
									  <input type="hidden" name="tInterfaceRegister.timestampCreate" value=""/>
									  <input type="hidden" class="hidden clean" name="stepNo" value=""/>
									  <div class="page-header f16">&nbsp; <i class="fa fa-cog"></i> 基本参数设置</div>
									  <div class="panel-body">
										  <div class="form-group col-lg-6">
											  <label class="col-lg-4 control-label" >工程标识</label>
											  <div class="col-lg-8">
												  <input name="tInterfaceRegister.sysEname" readonly="readonly"  class="form-control clean"/>
											  </div>
										  </div>
										  <div class="form-group col-lg-6">
											  <label class="col-lg-4 control-label" >IP地址</label>
											  <div class="col-lg-8">
												  <input name="tInterfaceRegister.serverIp" id="serverForm_serverIp" class="form-control" value="127.0.0.1" onblur="setInputVal('serverForm',this,'tInterfaceRegister.address')" maxlength="20" placeholder="服务器IP地址" data-bv-notempty="true" data-bv-notempty-message="此项不能为空"/>
											  </div>
										  </div>
										  <div class="form-group col-lg-6">
											  <label class="col-lg-4 control-label" >HTTP端口</label>
											  <div class="col-lg-8">
												  <input name="tInterfaceRegister.serverPort" class="form-control clean" maxlength="5" placeholder="设置http端口号，如tomcat的端口号" data-bv-notempty="true" data-bv-notempty-message="此项不能为空"  data-bv-regexp="true" data-bv-regexp-regexp="^(\d{4}|\d{5})$" data-bv-regexp-message="端口号必须是4~5位数字"  />
											  </div>
										  </div>
										  <div class="form-group col-lg-6">
											  <label class="col-lg-4 control-label" >Socket端口</label>
											  <div class="col-lg-8">
												  <input name="tInterfaceRegister.socketPort" id="serverForm_socketPort"  class="form-control clean" maxlength="5" onblur="setInputVal('serverForm',this,'tInterfaceRegister.port')" placeholder="设置RPC端口号" data-bv-notempty="true" data-bv-notempty-message="此项不能为空"  data-bv-regexp="true" data-bv-regexp-regexp="^(\d{4}|\d{5})$" data-bv-regexp-message="端口号必须是4~5位数字" />
											  </div>
										  </div>
									  </div>
								  </div>
								  <div class="panel panel-default" id="panel-div-rpc">
									  <div class="page-header f16">&nbsp; <i class="fa fa-server"></i> RPC接口参数设置</div>
									  <div class="panel-body">
										  <div class="form-group col-lg-6">
											  <label class="col-lg-4 control-label" >接口标识</label>
											  <div class="col-lg-8">
												  <input name="tInterfaceRegister.beanId" readonly="readonly"  class="form-control clean" value=""/>
											  </div>
										  </div>
										  <div class="form-group col-lg-6">
											  <label class="col-lg-4 control-label" >接口名称</label>
											  <div class="col-lg-8">
												  <input name="tInterfaceRegister.beanName" readonly="readonly"  class="form-control clean" value=""/>
											  </div>
										  </div>
										  <div class="form-group col-lg-6">
											  <label class="col-lg-4 control-label" >接口地址</label>
											  <div class="col-lg-8">
												  <input name="tInterfaceRegister.address" readonly="readonly"  class="form-control" value="127.0.0.1"/>
											  </div>
										  </div>
										  <div class="form-group col-lg-6">
											  <label class="col-lg-4 control-label" >接口端口</label>
											  <div class="col-lg-8">
												  <input name="tInterfaceRegister.port" readonly="readonly" class="form-control" maxlength="6"/>
											  </div>
										  </div>
										  <div class="form-group col-lg-6 hidden">
											  <label class="col-lg-4 control-label" >通讯协议</label>
											  <div class="col-lg-8">
												  <input name="tInterfaceRegister.callType" readonly="readonly" class="form-control" value="socket"/>
											  </div>
										  </div>
									  </div>
								  </div>

							  </div>
							  <!-- /.tab-pane -->
						  </div>
						  <!-- /.tab-content -->
					  </div>
					  <!-- nav-tabs-custom -->
				  </div>
				  <div class="box-footer">
					  <button type="button" class="btn btn-danger pull-right btn-lg" onclick="createServerProject();"><i class="fa fa-plus-circle"></i> 创建服务</button>
				  </div>
			  </form>
		  </div>
	  </div>
	  <!-- /.modal-content -->
  </div>
</div>

<script type="text/template" id="dataList-template">
<? for ( var i = 0; i < rows.length; i++) {?>
	<tr>
		<td style="display:none;"><?=rows[i].uctSys.sysId?></td>
		<td class="text-center"><?=(pageObj.currentPage-1)*10+(i+1)?></td>
		<td><a href="${ctx}/sendPage/<?=rows[i].uctSys.sysEname?>/admin/index" target="_bank"> <i class="fa fa-compass fx1"></i></a> <?=rows[i].uctSys.sysCname?></td>
		<td><?=rows[i].uctSys.sysEname?></td>
		<td><?=rows[i].uctSys.sysColor?></td>
		<td><?=getFormatDateByLong(rows[i].uctSys.createTime,"yyyy-MM-dd hh:mm:ss")?></td>
		<td>
			<button type="button" class="btn btn-warning btn-sm" <?if(rows[i].uctSys.sysEname=='plateform'){?> disabled="disabled" <?}?> onclick="viewSysAdmin('1','<?=rows[i].uctSys.sysEname?>','<?=rows[i].uctSys.sysCname?>');"><i class="fa fa-search-plus"></i> 管理后台</button>&nbsp;&nbsp;&nbsp;
			<button type="button" class="btn btn-info btn-sm" <?if(rows[i].uctSys.sysEname=='plateform' || rows[i].uctSys.userCenterFlag!='T'){?> disabled="disabled" <?}?> onclick="viewSysAdmin('2','<?=rows[i].uctSys.sysEname?>','<?=rows[i].uctSys.sysCname?>');"><i class="fa fa-search-plus"></i> 用户中心</button>&nbsp;&nbsp;&nbsp;
			<button type="button" class="btn btn-default btn-sm" <?if(rows[i].uctSys.sysEname=='plateform'){?> disabled="disabled" <?}?> onclick="changeCreateProject('2','<?=rows[i].uctSys.sysEname?>','<?=rows[i].uctSys.sysCname?>','<?=rows[i].uctSys.sysColor?>','<?=rows[i].uctSys.userCenterFlag?>','<?=rows[i].uctSys.userCenterColor?>');"><i class="fa fa-plus-circle"></i> 重新生成工程</button>&nbsp;&nbsp;&nbsp;
            <#if (loginUser.userEname=='admin')><button type="button" class="btn btn-default btn-sm" <?if(rows[i].uctSys.sysEname=='plateform'){?> disabled="disabled" <?}?> onclick="delSysAdmin('<?=rows[i].uctSys.sysId?>','<?=rows[i].uctSys.sysEname?>','<?=rows[i].uctSys.sysCname?>');"><i class="fa fa-trash-o"></i> 删除工程</button>&nbsp;&nbsp;&nbsp;</#if>
			<div class="hidden">
				<button type="button" class="btn btn-warning btn-sm" onclick="toLoad('<?=rows[i].uctSys.sysId?>','edit');"><i class="fa fa-edit"></i> 修改</button>&nbsp;&nbsp;&nbsp;
				<button type="button" class="btn btn-danger btn-sm" onclick="createProject('<?=rows[i].uctSys.sysEname?>','<?=rows[i].uctSys.sysCname?>','<?=rows[i].uctSys.sysColor?>','<?=rows[i].uctSys.userCenterFlag?>','<?=rows[i].uctSys.userCenterColor?>');"><i class="fa fa-clone"></i> 重新创建工程</button>
			</div>
			<button <?if(i==0){?>data-step="2" data-intro="后续操作均在管理控制台内。"<?}?> type="button" class="btn btn-primary btn-sm" onclick="pageToUrl('<?=rows[i].uctSys.sysEname?>','<?=rows[i].uctSys.sysCname?>');"><i class="fa fa-tv"></i> 进入管理控制台</button>&nbsp;&nbsp;
		</td>
	</tr>
<?}?>
</script>
<script type="text/template" id="dataListNew-template">
		  <? for ( var i = 0; i < rows.length; i++) {?>
	  <div class="col-lg-3">
		  <div class="box box-default box-solid home-box" <?if(i==0){?>data-step="2" data-intro="后续操作，请进入工程管理控制台内操作。"<?}?>>
			  <div class="box-body text-center lh25">
				  <div class="form-group fx1 f50"><i class="fa fa-compass"></i></div>
				  <div class="form-group fx16"><?=rows[i].uctSys.sysCname?></div>
				  <div class="form-group gray"><?=strUtil.timeAgoStr(rows[i].uctSys.createTime)?></div>
			  </div>
			  <div class="overlay">
				  <div class="actions">
					  <a href="javascript:;" onclick="pageToUrl('<?=rows[i].uctSys.sysEname?>','<?=rows[i].uctSys.sysCname?>');" class="action">进入管理控制台</a>
				  </div>
				  <div class="icons">
					<?if(rows[i].uctSys.sysEname!='plateform'){?>
					  <a href="javascript:;" onclick="viewSysAdmin('1','<?=rows[i].uctSys.sysEname?>','<?=rows[i].uctSys.sysCname?>');" class="action-icon" data-toggle="tooltip" data-placement="top" title="去往管理后台"><i class="fa fa-tv"></i></a>
					  <?if(rows[i].uctSys.userCenterFlag=='T'){?>
					  <a href="javascript:;" onclick="viewSysAdmin('2','<?=rows[i].uctSys.sysEname?>','<?=rows[i].uctSys.sysCname?>');" class="action-icon" data-toggle="tooltip" data-placement="top" title="去往用户中心"><i class="fa fa-user"></i></a>
					  <?}?>
					  <a href="javascript:;" onclick="changeCreateProject('2','<?=rows[i].uctSys.sysEname?>','<?=rows[i].uctSys.sysCname?>','<?=rows[i].uctSys.sysColor?>','<?=rows[i].uctSys.userCenterFlag?>','<?=rows[i].uctSys.userCenterColor?>');" class="action-icon" data-toggle="tooltip" data-placement="top" title="重新生成工程"><i class="fa fa-plus-circle"></i></a>
                      <#if (loginUser.userEname=='admin')>
					  	<a href="javascript:;" onclick="delSysAdmin('<?=rows[i].uctSys.sysId?>','<?=rows[i].uctSys.sysEname?>','<?=rows[i].uctSys.sysCname?>');"onclick="delSysAdmin('<?=rows[i].uctSys.sysId?>','<?=rows[i].uctSys.sysEname?>','<?=rows[i].uctSys.sysCname?>');" class="action-icon" data-toggle="tooltip" data-placement="top" title="删除工程"><i class="fa fa-trash-o"></i></a>
				  	  </#if>
					<?}?>
				  </div>
			  </div>
			  <div class="box-footer fx8">
				  <div class="box-tools text-center f12">
					  <div class="pull-left">
						  <?=(pageObj.currentPage-1)*16+(i+1)?>.<?=rows[i].uctSys.sysEname?>
					  </div>
					  <div class="pull-right">
						  <?=getFormatDateByLong(rows[i].uctSys.createTime,"yyyy-MM-dd hh:mm:ss")?>
					  </div>
				  </div>
			  </div>
		  </div>
	  </div>
	<?}?>
</script>
 <script>
var clickMenu = "sys-list";

myPage = 16;
searchFormId = "searchFrom";
tableId = "sysId";
isShowLog = true;
dataListId="dataListNew";
$(function () {
	//1、加载分页列表数据
    getTableDataNew();
 });


//给模态窗口内form表单内的所有支持必填项的元素注入校验
$(".modal").on('shown.bs.modal', function () {
    $(this).find("form").each(function () {
        var formId = $(this).attr("id");
        if (!strUtil.isNull(formId)) {
            formId = "#" + formId;
            setValidate(formId);//定义add表单验证属性
            mytools.cleanValidate(formId);//清空上次校验规则提示
        }
    });
});

/**
 * 当已经打开一个一级模态框之后，再继续打开一个二级模态框， 然后关闭二级模态框，一级模态框长度大于视窗的时候，会导致一级模态框无法向下滚动
 * */
$('.modal').on('hidden.bs.modal', function () {
    if ($('.modal.in').size() >= 1) {
        $('body').addClass('modal-open')
    }
})

//回车查询
document.onkeydown=function mykeyDown(e){
    //compatible IE and firefox because there is not event in firefox
    e = e||event;
    if(e.keyCode == 13) {getTableDataNew();}
    return;
};

//读取（查询、编辑）数据
function toLoad(id,type){
	$.ajax({ type:'get', url:"${ctx}/trans/info/sysInfo",dataType:'json',
	    data:{'sysId':id},
	    success: function(myData){
	    	 //console.log(myData);
	    	//$("#fileUpText_2_showImg").attr("src","");
	    	showData(type,myData);
	  	}
	});	
}
function toLoadBySysEname(sysEname){
    $.ajax({ type:'get', url:"${ctx}/trans/list/listSys",dataType:'json',
        data:{'sysEname':sysEname},
        success: function(myData){
			if(myData.total>0){
				showData("create",myData.rows[0]);
			}
        }
    });
}
function toAdds(){
	mytools.cleanData(".addFormBody");
	$("#my_modal").modal("show");
    $("input[type='radio'][name='radio_userCenterFlag'][value='F']").prop("checked", true);
    $("#div_userCenter").addClass("hidden");
}
//选择要重新生成的工程
function changeCreateProject(typeNo,sysEname,sysCname,sysColor,userCenterFlag,userCenterColor){
    var index_con = layer.confirm('请先选择工程['+sysEname+']需要重新生成的内容！', {closeBtn :0,btn: ['服务端程序工程','客户端页面工程']}
	, function(){
        toServerWin(typeNo,sysEname,sysCname);
        layer.close(index_con);
	},function () {
	    layer.close(index_con);
	    createProject(sysEname,sysCname,sysColor,userCenterFlag,userCenterColor)
	});
}
function toServerWin(typeNo,sysEname,sysCname){
    mytools.cleanData(".serverFormBody");
    $("#serverForm").find("input[name='tInterfaceRegister.sysEname']").val(sysEname);
    $("#serverForm").find("input[name='tInterfaceRegister.beanId']").val(sysEname+"Service");
    $("#serverForm").find("input[name='tInterfaceRegister.beanName']").val(sysCname+"服务接口");
    $("#serverForm").find("input[name='tInterfaceRegister.timestampCreate']").val(new Date().getTime());
    $("#serverForm").find("input[name='stepNo']").val(typeNo);
    if("2"==typeNo){
        $("#panel-div-rpc").addClass("hidden");
	}else{
        $("#panel-div-rpc").removeClass("hidden");
	}

    $("#my_modal_server").modal("show");
}
function checkIsUserCenter(f,inputId){
    $("#div_userCenter").find("select").val("");
    if("T"==f){
        $("#div_userCenter").removeClass("hidden");
	}else{
        $("#div_userCenter").addClass("hidden");
	}
	$("#"+inputId).val(f);
}
//反显数据
function showData(type,myData){
	console.log(myData);
	mytools.cleanData('.addFormBody');
	FormUtil.loadView("", myData);
	//alert(myData.sysUrl);
	if("view"==type){
		$("#my_modal_view").modal("show");
	}else if("edit"==type){
		$("#my_modal").modal("show");
		$("#fileUpText_2_showImg").attr("src",myData.sysUrl);
		if(strUtil.isNull(myData.userCenterFlag)){
            $("input[type='radio'][name='radio_userCenterFlag'][value='F']").prop("checked", true);
		}else{
            $("input[type='radio'][name='radio_userCenterFlag'][value='T']").prop("checked", true);
        }
		//alert($("#fileUpText_2_showImg")[0].src);
	}else if("create"==type){
	    layer.closeAll();
        $("#my_modal").modal('hide');
        $("#my_modal_create").modal("show");
    }
}
//保存系统数据
function saveItem(formId){
    var sysEname = $('#' + formId).find("input[name='uctSys.sysEname']").val();
    var sysCname = $('#' + formId).find("input[name='uctSys.sysCname']").val();
    var validate = $('#' + formId).data('bootstrapValidator').validate();
    if (!validate.isValid()) { //如果校验不通过就返回
        return;
    }
    $('#' + formId).find("input[name='uctSys.createTime']").val(new Date().getTime());

    //检测系统是否存在
    var msg_index = layer.msg("正在检测["+sysEname+"]，请稍候...");
    var flagExist = checkSystemIsExist(sysEname);
    if(flagExist){
        msg_index = layer.msg("此["+sysEname+"]工程标识已被使用，请更换！");
        return;
    }

    var index_submit = layer.confirm('您确定要提交数据吗？', {btn: ['Yes','No'],closeBtn: 0,offset: '220px'}
        , function() {
            layer.close(index_submit);
            var index_msg=layer.msg("正在保存数据中，请耐心等待...");
            $.ajax({
                type:'post',
                url:common_submit_url,
                data:$("#"+formId).serialize(),
                dataType:'json',
                success: function(myData){
                    console.log("add uctSys",myData);
                    if(myData.flag=='T'){
                        var sysId = myData.ids.uctSys_sysId;
                        addUctUserSys(sysId,sysEname,sysCname);
                        createWebProject();//创建web工程
                        //getTableDatas();
                        getTableDataNew();
                    }else{
                        layer.alert(myData.msg, {icon: 1,closeBtn: 0,offset: '220px'});
                    }
                }
            });
        });
}
/**
function getTableDatas(){
	deleteAllRow(dataListId);
	$.ajax({ type:'get', url:"${ctx}/trans/list/listSys",dataType:'json',
		   data:$("#"+searchFormId).serialize()+getCurrentPage("${ctx}/trans/list/listSys?"+$("#"+searchFormId).serialize(),myPage),
		   success: function(myData){
		   console.log(myData);
			var data = baidu.template(dataListId+"-template",eval(myData));  
			$("#"+dataListId+"-body").html(data);
			  var option= {
					   ele:$("#"+dataListId+"-page")[0],
					   total:myData.total,
					   fn:getTableDatas,
					   url:"${ctx}/trans/list/listSys"+"?"+$("#"+searchFormId).serialize()
				   };
				generatePages(option);
		   }
		});	
  }
**/
function getTableDataNew() {
    var index_load = layer.load(1, {shade: false});
//    dataListId = "dataListNew";
    $.ajax({
        type: 'get',
        url: common_list_url,
        data: $("#" + searchFormId).serialize() + getCurrentPage(common_list_url + "?" + $("#" + searchFormId).serialize(), myPage),
        dataType: 'json',
        success: function (myData) {
            console.log("getTableDataNew",myData);
            if(myData.flag=="T"){
                $("#dataListTotalCount").text(myData.total);
                var data = baidu.template(dataListId + "-template", eval(myData));
                $("#" + dataListId + "-body").html(data);
                var option = {
                    ele: $("#" + dataListId + "-page")[0],
                    total: myData.total,
                    fn: getTableDataNew,
                    url: common_list_url + "?" + $("#" + searchFormId).serialize()
                }
                generatePages(option);
                layer.close(index_load);

                initGuideIntroJs();
			}
        }
    });
}
//生成客户端页面工程
function createProject(sysEname,sysCname,sysColor,userCenterFlag,userCenterColor){
	var index_submit = layer.confirm('生成客户端工程会替换原工程目录下所有文件！是否继续操作？', {btn: ['确认继续','放弃'],closeBtn: 0,offset: '220px'}
	, function(){
		layer.close(index_submit);
		$.ajax({ type:'post', url:"${ctx}/common/coding/createProject",dataType:'json',
			   data:{"sysEname":sysEname,"sysCname":sysCname,"sysColor":sysColor,"userCenterFlag":userCenterFlag,"userCenterColor":userCenterColor},
			   success: function(myData){
			   	   layer.alert(myData.msg);
			   }
		});
	});
}

function getModuleData(title,code,sysEname,fatherId,num,orderNo){
    var paramData = {};
    paramData["pageName"]="sysModule-list";
    paramData["formName"]="addForm";
    paramData["sysModule.fatherId"]=fatherId;
    paramData["sysModule.delStatus"]="F";
    paramData["sysModule.cateNo"]=code;
    paramData["sysModule.cateName"]=title;
    paramData["sysModule.num"]=num;
    paramData["sysModule.ifLast"]="F";
    paramData["sysModule.title"]=title;//名称
    paramData["sysModule.code"]=code;//标识
    paramData["sysModule.ifShow"]="T";//是否显示
    paramData["sysModule.orderNo"]=orderNo;//排序号
    paramData["sysModule.sysName"]=sysEname;//所属工程
    paramData["sysModule.isCustom"]="F";//是否自定义
	if("2"==num){
        paramData["sysModule.menuId"]=code;//排序号
	}
	return paramData;
}
//初始化系统模块
function addSysModule(sysEname,sysCname){
    var msg_load = layer.msg("正在初始化系统菜单数据，请耐心等待...");
    var paramData = getModuleData(sysCname,sysEname,sysEname,"0","0","0");
    $.ajax({
        type:"post",url:common_submit_url,data: paramData,dataType:"json",async:false,
        success: function(myData){
            console.log("add.module",myData);
            if(myData.flag=="T" && !strUtil.isNull(myData.ids)){
                var modulefatherId = myData.ids.sysModule_moduleId;
                var paramDataChild_1 = getModuleData("测试菜单一","test-first",sysEname,modulefatherId,"1","1");
                var paramDataChild_2 = getModuleData("测试菜单二","test-second",sysEname,modulefatherId,"1","2");
                msg_load = layer.msg("一级菜单[测试菜单一]初始化中...");
                $.ajax({
                    type:"post",url:common_submit_url,data: paramDataChild_1,dataType:"json",async:false,
                    success: function(myData){
                        console.log("add.module",myData);
                        if(myData.flag!="T"){
                            msg_load = layer.msg("一级菜单[测试菜单一]初始化失败："+myData.msg);
                        }else{
                            var modulechildId = myData.ids.sysModule_moduleId;
                            var paramDataChild_1_1 = getModuleData("功能一","test-child-node",sysEname,modulechildId,"2","1");
                            paramDataChild_1_1["sysModule.ifLast"]="T";
                            paramDataChild_1_1["sysModule.pageRoot"]="/"+sysEname+"/admin/test/";
                            paramDataChild_1_1["sysModule.pageUrl"]="/"+sysEname+"/admin/test/test-child-node";
                            msg_load = layer.msg("二级菜单[测试菜单一/功能一]初始化中...");
                            $.ajax({
                                type:"post",url:common_submit_url,data: paramDataChild_1_1,dataType:"json",async:false,
                                success: function(myData){
                                    console.log("add.module.child",myData);
                                    if(myData.flag!="T"){
                                        msg_load = layer.msg("二级菜单[测试菜单一/功能一]初始化失败："+myData.msg);
                                    }
                                }
                            });
						}
                    }
                });
                msg_load = layer.msg("一级菜单[测试菜单二]初始化中...");
                $.ajax({
                    type:"post",url:common_submit_url,data: paramDataChild_2,dataType:"json",async:false,
                    success: function(myData){
                        console.log("add.module",myData);
                        if(myData.flag!="T"){
                            msg_load = layer.msg("一级菜单[测试菜单二]初始化失败："+myData.msg);
                        }
                    }
                });
                layer.close(msg_load);
            }else{
                layer.alert("初始化菜单数据，操作失败");
			}
        }
    });
}

//添加用户负责的系统。
function addUctUserSys(sysId,sysEname,sysCname) {
    var msg_load = layer.msg("正在添加系统管理员，请耐心等待...");
    var paramData = {};
    paramData["modelTypes"]="i_uctUserSys";
    paramData["uctUserSys.sysNo"]=sysEname;
    paramData["uctUserSys.userEname"]="${loginUser.userEname}";
    paramData["uctUserSys.userId"]="${loginUser.userId}";
    paramData["uctUserSys.orgId"]="${loginUser.orgId}";
    paramData["uctUserSys.deptId"]="${loginUser.deptId}";
    paramData["uctUserSys.sysId"]=sysId;
    paramData["uctUserSys.sysName"]=sysCname;
    $.ajax({
        type:"post",url:common_submit_url,data: paramData,dataType:"json",async:false,
        success: function(myData){
            console.log("add.uctUserSys",myData);
            if(myData.flag=="T" && !strUtil.isNull(myData.ids)){
                layer.close(msg_load);
            }else{
                layer.alert("添加系统管理员，操作失败！");
            }
        }
    });

}

//创建web工程
function createWebProject(){
    var index_msg=layer.msg("正在创建WEB工程，请耐心等待...");
    var sysEname=$("#submitForm").find("input[name='uctSys.sysEname']").val();
    var sysCname=$("#submitForm").find("input[name='uctSys.sysCname']").val();
    var sysColor =$("#submitForm").find("input[name='uctSys.sysColor']").val();
    var userCenterFlag =$("#submitForm").find("input[name='uctSys.userCenterFlag']").val();
    var userCenterColor =$("#submitForm").find("input[name='uctSys.userCenterColor']").val();
    var codingData = {};
    codingData["sysEname"]=sysEname;
    codingData["sysCname"]=sysCname;
    codingData["sysColor"]=sysColor;
    codingData["userCenterFlag"]=userCenterFlag;
    codingData["userCenterColor"]=userCenterColor;
    $.ajax({ type:'post', url:"${ctx}/common/coding/createProject",dataType:'json',
        data:codingData,
        success: function(myData){
        	console.log("createWebProject",myData);

            addSysModule(sysEname,sysCname);//添加系统根目录菜单模块

            if("T"==myData.flag){
                layer.confirm('工程【'+sysCname+'】已创建完成！', {
                    btn: ['知道了','关闭'] //按钮
                }, function(){
                    $("#my_modal").modal("hide");
                    layer.closeAll();
                }, function(){
                    $("#my_modal").modal("hide");
                    layer.closeAll();
//                    $("#my_modal").modal("hide");
//                    layer.closeAll();
//                    toServerWin('1',sysEname,sysCname);
                });
            }else{
                layer.alert(myData.msg);
            }
        }
    });
}
//创建server工程
function createServerProject(){
    var formId = "#serverForm";
    var validate = $(formId).data('bootstrapValidator').validate();
    if (!validate.isValid()) { //如果校验不通过就返回
        return;
    }

    var stepNo = $(formId).find("input[name='stepNo']").val();

    //检测检测Socket端口是否存在
	var serverPort = $(formId).find("input[name='tInterfaceRegister.serverPort']").val();
    var serverIp = $(formId).find("input[name='tInterfaceRegister.serverIp']").val();
    var socketPort = $(formId).find("input[name='tInterfaceRegister.socketPort']").val();
    if(serverPort==socketPort){
        layer.msg("Socket端口和HTTP端口不能重复！");
        return;
	}
    var msg_index = layer.msg("正在检测Socket端口，请稍候...");
    var flagExist = checkRpcIsExist(serverIp,socketPort);
    if(flagExist){
        msg_index = layer.msg("此IP地址的Socket端口["+socketPort+"]已被使用，请更换！");
        $(formId).find("input[name='tInterfaceRegister.socketPort']").select();
        return;
    }

    var index_submit = layer.confirm('确认开始创建操作吗？', {btn: ['确认继续','放弃'],closeBtn: 0,offset: '220px'}
	, function(){
		var codingData = {};
		codingData["sysEname"]=$(formId).find("input[name='tInterfaceRegister.sysEname']").val();
		codingData["serverIp"]=serverIp;
		codingData["serverPort"]=serverPort;
		codingData["socketPort"]=socketPort;
		layer.close(index_submit);
		var index_msg=layer.msg("正在创建服务端工程，请耐心等待...");
		$.ajax({ type:'post', url:"${ctx}/common/coding/createServerProject",dataType:'json',
			data:codingData,
			success: function(myData){
				console.log("createServerProject",myData);
				if("T"==myData.flag){
					var downLoadPath = myData.msg;
					layer.confirm('服务端工程创建完成，请下载！', {
						btn: ['Download工程包','取消'] //按钮
					}, function(){
						window.open(downLoadPath);
						layer.closeAll();
						index_msg=layer.msg("工程正在下载中...");
					}, function(){
						layer.closeAll();
						//$("#my_modal_server").modal("hide");
					});
                    saveRpcInterface();//保存接口

//                    if("1"==stepNo){
					     //mytools.addTestDatasource(defSysEname);
//                    }
				}else{
					layer.alert(myData.msg);
				}

			}
		});
	});
}
//保存rpcInterface接口地址。
function saveRpcInterface(){
    //var index_msg=layer.msg("正在创建RPC服务，请耐心等待...");
    var formId = "serverForm";
    $.ajax({ type:'post', url:common_submit_url,dataType:'json',data:$("#"+formId).serialize(),
        success: function(myData){
            console.log("add.rpcInterface",myData);
            if(myData.flag=='T'){
                //layer.msg("RPC服务创建成功！");
            }else{
                //layer.msg("RPC服务创建失败！");
            }
        }
    });
}

//（预览工程）
function viewSysAdmin(type,sysEname,sysCname){
    strUtil.setLocalStorage("sysEname",sysEname);
    strUtil.setLocalStorage("sysCname",sysCname);
    var sysLocalUrl  = ctx+"/sendPage/"+sysEname+"/admin/index";
    if(type=='2'){
        sysLocalUrl  = ctx+"/sendPage/"+sysEname+"/web/user/index";
	}
    window.open(sysLocalUrl);
}
//页面跳转-进入管理控制台
function pageToUrl(sysEname,sysCname) {
    strUtil.setLocalStorage("sysEname",sysEname);
    strUtil.setLocalStorage("sysCname",sysCname);
    window.location.href="${page_admin}/project/index?se="+$.base64.encode(sysEname);
}
//当前文本框值给name文本框赋值
function setInputVal(formId,obj,name){
    $("#"+formId).find("input[name='"+name+"']").val($(obj).val());
}
//检测RPC服务接口是否重复
function checkRpcIsExist(ip,port){
    var checkReturn = false;
    $.ajax({ type:'get', url:common_list_url,dataType:'json',async:false,
        data:{"pageName":"server-list","formName":"searchForm","tInterfaceRegister.w_address":ip,"tInterfaceRegister.w_port":port},
        success: function(myData){
            console.log("checkRpcIsExist",myData);
            if(myData.total>0){
                checkReturn=true;
			}
        }
    });
    return checkReturn;
}
//检测系统工程是否重复
function checkSystemIsExist(sysEname) {
    var checkReturn = false;
		$.ajax({ type:'get', url:common_list_url,dataType:'json',async:false,
        data:{"pageName":"uct-sys","formName":"searchForm","uctSys.sysEname":sysEname},
        success: function(myData){
            console.log("checkSystemIsExist",myData);
            if(myData.total>0){
                checkReturn=true;
            }
        }
    });
    return checkReturn;
}
//删除系统工程
function delSysAdmin(sysId,sysEname,sysCname) {
    var index_load = layer.msg("正在检查工程数据！");
    $.ajaxSettings.async = false;
    index_load = layer.load(1, {shade: false}); //0代表加载的风格，支持0-2
    var checkReturn = false;
    $.getJSON(common_list_url, {"pageName":"sysModule-list","formName":"searchForm","sysModule.sysName":sysEname}, function(myData){
        console.log(myData);
        if(myData.total>0){ layer.msg("请先删除【"+sysCname+"】下相关【菜单模块】数据！"); checkReturn=true;}
	});
    if(checkReturn){layer.close(index_load);return;}

    $.getJSON(common_list_url, {"modelTypes":"s_sortInfo","doCode":"dymicSql","sortInfo.sysName":sysEname}, function(myData){
        console.log(myData);
        if(myData.total>0){ layer.msg("请先删除【"+sysCname+"】下相关【数据表】数据！"); checkReturn=true;}
    });
    if(checkReturn){layer.close(index_load);return;}

    $.getJSON(common_list_url, {"modelTypes":"s_sysParamManager","sysParamManager.sysName":sysEname}, function(myData){
        console.log(myData);
        if(myData.total>0){ layer.msg("请先删除【"+sysCname+"】下相关【接口参数】数据！");checkReturn=true;}
    });
    if(checkReturn){layer.close(index_load);return;}

    $.getJSON(common_list_url, {"pageName":"sysPluginManager-list","formName":"searchForm","sysPluginManager.sysName":sysEname}, function(myData){
        console.log(myData);
        if(myData.total>0){ layer.msg("请先删除【"+sysCname+"】下相关【插件】数据！");checkReturn=true;}
    });
    if(checkReturn){layer.close(index_load);return;}

    $.getJSON(common_list_url, {"doCode":"dictCateList","sysEname":sysEname}, function(myData){
        console.log(myData);
        if(myData.total>0){ layer.msg("请先删除【"+sysCname+"】下相关【数据字典】数据！");checkReturn=true;}
    });
    if(checkReturn){layer.close(index_load);return;}

    $.getJSON(common_list_url, {"pageName":"uct-user-sys-list","formName":"searchForm","uctUserSys.w_sysNo":sysEname}, function(myData){
        console.log(myData);
        if(myData.total>0){ layer.msg("请先删除【"+sysCname+"】下相关【系统管理员】数据！");checkReturn=true;}
    });
    if(checkReturn){layer.close(index_load);return;}

    //后续还得补充删除文件
    $.ajaxSettings.async = true;

    layer.closeAll();
    var index_submit = layer.confirm("删除后不可恢复，确认要删除工程【"+sysCname+"】吗？", {btn: ['确认继续','放弃'],closeBtn: 0,offset: '220px'}
	, function(){
		layer.close(index_submit);
		$.ajax({ type:'post', url:common_submit_url,dataType:'json',data:{"pageName":"uct-sys","formName":"delForm","uctSys.w_sysId":sysId},
			success: function(myData){
				console.log(myData);
				if(myData.flag=='T'){
					layer.msg("删除操作成功！");
				}else{
					layer.msg("删除操作失败！");
				}
                getTableDataNew();
			}
		});
	});

}

//打开主题选择器窗口
function openThemeModal(inputId){
    var fileName = "";
    var file_url = "${page_admin}/theme-selection?flagId="+inputId;
    layer.open({
        type: 2,title: "主题选择器",
        shadeClose: false,shade: false,maxmin: false,area: ['500px', '300px'],
        content: file_url
    });
}

/**** Part 四、以下是自定义新增方法  ****/
//1.定义校验规则-定义
function setValidate(id) {
    $(id).each(function () {
        $(this).bootstrapValidator({
            feedbackIcons: {
                valid: 'glyphicon glyphicon-ok',
                invalid: 'glyphicon glyphicon-remove',
                validating: 'glyphicon glyphicon-refresh'
            }, /** 以下需要结合实际业务清空补充个表单元素的验证规则 **/
            fields: {
                /** 可自定义新增验证规则
                 "uctUser.userEname":{
                                    validators: {
                                    regexp: {
                                    regexp: /^[0-9]+$/,
                                    message: '只能是数字'
                                    }
                                    }
                                    }
                 **/
            }
        });
    });
}

//判断是否第一次进入，启用步骤引导提示
function initGuideIntroJs() {
    if(strUtil.isNull(strUtil.getLocalStorage("_iussoft_intro_home_sys"))){
        strUtil.setLocalStorage("_iussoft_intro_home_sys","T");
        showGuideIntroJs();
    }
}

</script>

    
    
    
    
  </div>
  <!-- /.content-wrapper -->
  <!-- foot start -->
	<#include "/common/plateform/foot.html">
  <!-- foot start -->
  


 
</body>
	


</html>
